home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Netrunner 2004 October
/
NETRUNNER0410.ISO
/
regular
/
sleipnir165.exe
/
{app}
/
developers
/
TypeLib
/
showlink
/
showlink.cpp
next >
Wrap
Text File
|
2004-07-12
|
2KB
|
78 lines
// showlink.cpp
#include <windows.h>
#import <shdocvw.dll> rename_namespace("SHDOCVW") named_guids
#import <mshtml.tlb> rename_namespace("MSHTML") named_guids
#import "..\Sleipnir.tlb" rename_namespace ("Sleipnir") named_guids
void Run(Sleipnir::IAPIPtr& pnir)
{
MSHTML::IHTMLDocument2Ptr document;
long id = pnir->GetDocumentID(pnir->ActiveIndex);
document = pnir->GetDocumentObject(id);
if (document == 0) {
pnir->MessageBox("Document âIâuâWâFâNâgé≡ì∞ɼé┼é½é▄é╣é±");
} else {
MSHTML::IHTMLElementCollectionPtr links = document->links;
if (links) {
for (int i=0; i<links->length; i++) {
MSHTML::IHTMLElementPtr elm = links->item(&_variant_t((long)i), &_variant_t((long)i));
if (elm) {
MSHTML::IHTMLAnchorElementPtr anchorElm = elm;
if (anchorElm) {
BSTR href;
anchorElm->get_href(&href);
elm->insertAdjacentHTML("AfterEnd", _bstr_t("<b><small>(") + href + ")</small></b>");
anchorElm = 0;
}
elm = 0;
}
}
links = 0;
}
}
pnir->Beep();
document = 0;
}
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmd, int nShow)
{
if (FAILED(CoInitialize(NULL))) {
MessageBox(NULL, "Failed \"CoInitialize\"", "Error", MB_OK|MB_ICONERROR);
return -1;
}
Sleipnir::IAPIPtr ApiPointer;
try {
HRESULT hr;
hr = ApiPointer.CreateInstance(Sleipnir::CLSID_API);
if (FAILED(hr))
_com_issue_error(hr);
}
catch (_com_error& e) {
MessageBox(NULL, e.ErrorMessage(), "Error", MB_OK|MB_ICONERROR);
return -1;
}
try {
Run(ApiPointer);
}
catch (_com_error& e) {
MessageBox(NULL, e.ErrorMessage(), "Error", MB_OK|MB_ICONERROR);
return -1;
}
ApiPointer = 0;
CoUninitialize();
return 0;
}